﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BLL.Model.Repositories;
using BLL.Utils;

namespace BLL.Model.Voucher
{
    public abstract class VoucherBase : Record
    {
        protected VoucherBase(IRecordRepository recordRepository)
            : base(recordRepository)
        {
        }

        public bool IsFixedAsset;
        public FixedAsset.FixedAsset FixedAsset;

        public double Amount;

        public override string VoucherNo
        {
            get { return VoucherNumberHelper.GetVoucherNumber(VoucherTypeKey, VoucherSerialNo); }
        }

        public override string LedgerType
        {
            get { return "LedgerBook"; }
        }

        public bool IsValid()
        {
            // TODO: write all validity condition for this VoucherBase 
            return true;
        }

        public override bool Save()
        {
            if (IsFixedAsset)
                return RecordRepository.InsertLedgerBookRow(this, FixedAsset);
            return RecordRepository.InsertLedgerBookRow(this);
            //TODO: do same for Credit voucher and journal Voucher
        }

    }
}

